package com.forlove.app.common.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.forlove.app.R;

/**
 * Created by yjl on 2017/10/12.
 */

public class SetItemView extends LinearLayout {
    private View mRootView;
    private Context mContext;

    TextView text_item_name;
    TextView text_subtitle;


    public SetItemView(Context context) {
        super(context);
        initView(context);
    }

    public SetItemView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public SetItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context mContext) {
        this.mContext = mContext;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mRootView = inflater.inflate(R.layout.item_set_config, this);
        text_item_name = (TextView) mRootView.findViewById(R.id.text_item_name);
        text_subtitle = (TextView) mRootView.findViewById(R.id.text_subtitle);
    }

    public void setSubtitle(String subtitle) {
        text_subtitle.setText(subtitle);
        text_subtitle.setVisibility(VISIBLE);
    }

    public void setTitle(String title) {
        text_item_name.setText(title);
    }

    public void setItemOnClickListener(OnClickListener itemOncliclistener) {
        mRootView.setOnClickListener(itemOncliclistener);
    }

}
